package com.carpedil.movie.service.impl;

import com.carpedil.movie.entity.Movie;
import com.carpedil.movie.mapper.MovieMapper;
import com.carpedil.movie.service.MovService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/** @author Administrator */
@Service
public class MovieServiceImpl implements MovService {
  @Autowired MovieMapper movieMapper;

  @Override
  public String check(String movieName) {
    Movie movie = movieMapper.findByMovieName(movieName);
    if (null == movie) {
      return "null";
    }
    return movie.getNum() >= 1 ? "1" : "-1";
  }

  @Override
  public boolean updateStorage(String movieName) {
    return movieMapper.updateStorageByName(movieName) > 0;
  }
}
